package net.bolue.web.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bolue.console.model.UpdateModel;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.model.UpdResModel;
import net.bolue.sysmng.tblbean.DbopResMap;
import net.bolue.sysmng.tblbean.UpdRes;
import net.bolue.web.report.RepConstants;
import net.bolue.web.util.RequestUtil;

/**
 * 批量更新
 * @author Administrator
 *
 */
public class BatchUpdAction extends AbstractAction{

	@Override
	public ActionResult perform(HttpServletRequest request,
			HttpServletResponse response) throws BolueException {
		String subSys = RequestUtil.getParamValue(request, RepConstants.REP_SUBSYS_KEY);
		String repId = RequestUtil.getParamValue(request, RepConstants.REP_REPID_KEY);
		if(subSys==null || subSys.trim().length()==0 || repId==null || repId.trim().length()==0){
			throw new BolueException(1, "批量更新URL中必须提供subSys及repID参数值!");
		}
		
		UpdResModel updResModel = new UpdResModel(request);
		DbopResMap dbopResMap = updResModel.getUpdResMap(subSys, repId);
		if(dbopResMap==null){
			throw new BolueException(7, "没有找到报表"+subSys+"."+repId+"的批量更新资源映谢!");
		}
		UpdRes updRes = updResModel.getUpdRes(subSys, dbopResMap.getResId());
		if(updRes==null){
			throw new BolueException(10, "没有找到subSys="+subSys+",updateID="+dbopResMap.getResId()+"的更新记录所用资源！");
		}
		
		UpdateModel handler = new UpdateModel(request,updRes);
		return handler.update();
	}

}
